package io.bluefw.blueui.dsl.render;

import java.util.List;
import java.util.Map;

import io.bluefw.blueui.dsl.Entity;
import io.bluefw.blueui.dsl.Part;
import io.bluefw.blueui.dsl.Toolbar;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class PageWidget extends Render {
	private Map<String, Object> props;
	private Toolbar toolbar;
	private List<Part> parts;

	public PageWidget(String templateName) {
		super(templateName);
	}

	public void setType(String type) {
		this.setTemplateName(type + ".ftl");
	}
	
	public void setEntity(Entity entity) {
		for (Part part : parts) {
			part.setEntity(entity);
		}
	}
	
	@Override
	public StringBuffer render() {
		return this.freemarker.render(this, this.getTemplateName());
	}
	
}
